#include <stdio.h>
#include <math.h>
#include <time.h>
double my_sqrt (double param)
{
/* precondition: num >= 0
 * postcondition: if num < 0 the answer is invalid,
 * otherwise the square root is returned.
 * method: divide and average */
double epsilon = 0.001;
double guess;
if (param <= 0.0)
return param;
else
guess = param/2.0;
/* Write here the loop that approximate the divide and average method */
while(fabs(pow(guess,2) - param) > epsilon){
guess = (param/guess + guess)/2.0;
}


return guess;
}
int main ()
{
double  result;
double param;
printf ("enter the number:");
//fflush(stdin);
scanf ("%lf", &param);
result = my_sqrt ((double)param);
printf ("my_sqrt(%lf) = %lf\n", param, result );
return 0;
}
